package com.ls.userlog.controller;

import com.ls.userlog.annocation.RiseLog;
import com.ls.userlog.entity.User;
import com.ls.userlog.service.UserOperateLogService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@Slf4j
public class UserController {

    @Autowired
    private UserOperateLogService userOperateLogService;

    @GetMapping("/get")
    @RiseLog(operateName = "通过id查找人员")
    public User findById(@RequestParam("id") String id){
        User result = userOperateLogService.select(id);
        return result;
    }


    @PostMapping("/add")
    @RiseLog(operateName = "添加人员")
    public Integer saveUser(@RequestBody User user){
        Integer add = 0;
//        int i = 1/0;
        add = userOperateLogService.add(user);
        return add;
    }
}
